/* the reason is that two consecutive numbers differ by a factor of +1 ie the rightmost bit and as a result an AND operation on the two rightmost bits gives 0.Hence eliminating the rightmost bit*/

#include<stdio.h>
int main()
{
 unsigned x;
 int i=0;
 printf("enter a number");
 scanf("%u",&x);
 while(x!=0)
 {
  x=x & (x-1);
  i++;
 }  
 printf("the number of 1's are %d",i);
 return 0;
}
 
